var Banks = function () {
	
	var options;
	
	var grid = new Datatable();

    var handle = function () {
    	
        grid.init({
            src: $("#datatable_banks"),
            fixedColumns: 1,
            onSuccess: function (data) {
            	
            },
            onError: function (data) {
               
            },
            dataTable: {
                "pageLength": 10,
                "ajax": {
                    "url": options.ctx + '/bank/list'
                },
                "columnDefs": [{'orderable': false, 'targets': [0]}],
                "columns": [
                            {"data": "id", "render": function(data,type,full) {
								return '<div class="btn-group">'+
										'	<a href="#" class="btn blue-madison btn-xs btn-operation" data-toggle="dropdown">'+
										'		<i class="fa fa-cog"></i> ' + message['datatable.operation'] + 
										'	</a>'+
										'	<ul class="dropdown-menu pull-left">'+
										'		<li><a href="' + options.ctx + '/bank/update/' + full.id + '" data-toggle="modal" data-target="#ajax-modal">修改</a></li>'+
										'		<li><a href="#this" onClick="Banks.Delete(' + full.id + ', \'' + full.name + '\')">删除</a></li>'+
										'		<li><a href="' + options.ctx + '/companybankcard/list?bankName=' + full.name + '" target="_blank">查看公司银行卡</a></li>'+
										'	</ul>'+
										'</div>';
							}},
                            {"data": "code"},
                            {"data": "name"},
                            {"data": "url", "render": function(data,type,full) {
								return '<a href="' + data + '" target="_blank">' + data + '</a>';
							}},
                            {"data": "rechargeDemoUrl", "render": function(data,type,full) {
								return '<a href="' + data + '" target="_blank">' + data + '</a>';
							}},
							{"data": "bankTransferStatus", "render": function(data,type,full) {
                            	return data == 'OPEN' ? '<span class="label label-sm label-success">' + message['net.lanelife.casino.caipiao.entity.Bank.BankTransferStatus.OPEN'] + '</span>' : '<span class="label label-sm label-danger">' + message['net.lanelife.casino.caipiao.entity.Bank.BankTransferStatus.CLOSE'] + '</span>';
                            }},
							{"data": "allowBindingStatus", "render": function(data,type,full) {
                            	return data == 'OPEN' ? '<span class="label label-sm label-success">' + message['net.lanelife.casino.caipiao.entity.Bank.AllowBindingStatus.OPEN'] + '</span>' : '<span class="label label-sm label-danger">' + message['net.lanelife.casino.caipiao.entity.Bank.AllowBindingStatus.CLOSE'] + '</span>';
                            }},
                            
							{"data": "createdBy"},
                        	{"data": "createdDate"},
                        	{"data": "lastModifiedBy"},
                        	{"data": "lastModifiedDate"}
                        ],
                "order": [
                    [2, "asc"]
                ]
            }
        });
        
    };

    return {
        init: function (opts) {
			options = $.extend(true, {}, opts);
            handle();
        },
		
		Delete: function(id, name) {
			bootbox.confirm("确定删除 " + name + " 吗？", function(result) {
			   if (result) {
				   Metronic.sendRequest({
					   url: options.ctx + '/bank/delete/' + id,
					   dataTable: grid.getDataTable()
				   });
			   }
			}); 
		}
    };

}();

